<template>
  <div class="shopcart">
    <h1>
      <span class="iconfont icon-zuojiantou" @click="fun()"></span>
      <span>购物车</span>
    </h1>
    <div class="container">
      <img src="@/assets/img/cart.png" alt="" />
      <p>购物车还是空的</p>
      <p>赶紧买点宝贝慰劳下自己吧</p>
      <p @click="funa()">去逛逛</p>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    fun() {
      this.$router.push("/mine");
    },
    funa() {
      this.$router.push("/market");
    },
  },
  beforeRouteEnter(to, from, next) {
    // console.log(to);
    // console.log(from);
    console.log("进来了");
    next();
  },
beforeRouteLeave(to,from,next){
    console.log("离开了");
    // console.log(to);
    // console.log(from);
    next()
    if(confirm("您确定要离开吗？")){
        next()
    }else{
        next(false)
    }
}
};
</script>

<style scoped>
.shopcart {
  height: 6.67rem;
  background-color: rgb(238, 239, 243);
}
h1 {
  background-color: #fff;
  font-size: 0.24rem;
  font-weight: 700;
  height: 0.5rem;
  line-height: 0.5rem;
  border-bottom: 0.01rem solid #999;
}
.icon-zuojiantou {
  font-size: 0.24rem;
  font-weight: 700;
  padding-right: 1.4rem;
}
.container {
  background-color: rgb(238, 239, 243);
  height: 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #666;
}
.container img {
  width: 2rem;
}
.container p:nth-child(4) {
  width: 0.8rem;
  height: 0.3rem;
  border: 0.01rem solid red;
  border-radius: 0.15rem;
  color: red;
  text-align: center;
  line-height: 0.3rem;
  margin-top: 0.2rem;
}
.container p:nth-child(2) {
  padding: 0.2rem 0;
  color: black;
}
</style>